// EDComponentType.cpp: implementation of the EDComponentType class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "EDComponentType.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CArray<EDComponentType*,EDComponentType*> EDComponentType::m_arpCT;

EDComponentType::EDComponentType() :
	m_strAppId ( _T ( "" ) ), m_strStandard ( _T ( "" ) ), m_strNamedType ( _T ( "" ) )
{
}

EDComponentType::~EDComponentType()
{
}

EDComponentType::EDComponentType (
	const CString& strAppId,
	const CString& strStandard,
	const CString& strNamedType ) :
	m_strAppId ( strAppId ), m_strStandard ( strStandard ), m_strNamedType ( strNamedType )
{
}

//////////////////////////////////////////////////////////////////////
// Static functions
//////////////////////////////////////////////////////////////////////

BOOL EDComponentType::IsEqualTo ( const EDComponentType& ct )
{
	if ( m_strAppId.CompareNoCase ( ct.m_strAppId ) == 0
		&& m_strStandard.CompareNoCase ( ct.m_strStandard ) == 0
		&& m_strNamedType.CompareNoCase ( ct.m_strNamedType ) == 0 )
		return TRUE;
	return FALSE;
}

EDComponentType* EDComponentType::RegisterCT ( EDComponentType* pCT )
{
	for ( int i = 0; i < EDComponentType::m_arpCT.GetSize(); i++ )
	{
		if ( EDComponentType::m_arpCT.GetAt ( i )->IsEqualTo ( *pCT ) )
			return EDComponentType::m_arpCT.GetAt ( i );
	}
	EDComponentType::m_arpCT.Add ( pCT );
	return pCT;
}

EDComponentType* EDComponentType::RegisterCT (
	const CString& strAppId,
	const CString& strStandard,
	const CString& strNamedType )
{
	EDComponentType* pCT = new EDComponentType ( strAppId, strStandard, strNamedType );
	EDComponentType* ptr = EDComponentType::RegisterCT ( pCT );
	if ( ptr != pCT )
		delete pCT;
	return ptr;
}
